package com.bup.gn.service.impl;

import com.bup.gn.dao.UserDao;
import com.bup.gn.model.User;
import com.bup.gn.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService, UserDetailsService {
    @Autowired
    private UserDao userDao;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        return userDao.findByUserId(username);
    }

    @Override
    public void updateAccount(User account) {

    }

    @Override
    public void deleteAccount(int id) {

    }

    @Override
    public void createAccount(User user) {
        user.setActive(true);
        userDao.save(user);
    }

    @Override
    public void confirmAccount(String key) {

    }

    @Override
    public void sendResetPassword(User account) {

    }

    @Override
    public boolean checkEmail(String email) {
        return userDao.findByUserId(email) != null;
    }

    @Override
    public User findByKey(String securityToken) {
        return null;
    }
}
